package com.web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.domain.PageBean;
import com.service.GoodsService;
import com.service.Impl.GoodsServiceImpl;

@WebServlet("/findPageServlet")
public class FindPageServlet extends HttpServlet{
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //创建GoodsServlet对象获取PageBean对象
        GoodsService goodsServlet = new GoodsServiceImpl();

        //获取当前页码
        String currentPage = request.getParameter("currentPage");
        //获取超连接标签的id值
        String id = request.getParameter("id");
        System.out.println(id);

        //调用PageBean对象
        PageBean pageBean = goodsServlet.findPage(currentPage,id);

        System.out.println(pageBean);

        //将PageBean存储都request域中
        request.setAttribute("pageBean", pageBean);
        request.setAttribute("id", id);
        //转发到展示商品的页面
        request.getRequestDispatcher("/page/ITpage.jsp").forward(request, response);
    }
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doGet(req, resp);
	}
}
